import Vue from 'vue';
import Vuex from 'vuex';
import actions from './actions';
import mutations from './mutations';
import getters from './getters';
import state from './state';
import login from './modules/login';
import menu from './modules/menu';
import pagination from './modules/pagination';
import editWorkFlow from './modules/editWorkFlow';
import workflow from './modules/workflow';
import intelligentReply from './modules/intelligentReply';
import sceneInfo from './modules/sceneInfo';
import uploadVideo from './modules/uploadVideo';
// import localSvae from './plugins/localSvae'
import createPersistedState from 'vuex-persistedstate';
import form from './modules/form';
import editWorkingTime from './modules/editWorkingTime';
import calendar from './modules/calendar';
import systemSetting from './modules/systemSetting';
import associatedVariable from './modules/associatedVariable';
import variable from './modules/variable';

console.log('workflow : ', workflow, login);

Vue.use(Vuex);

const dataState = createPersistedState({
	paths: ['login', 'menu', 'pagination']
});

const store = new Vuex.Store({
	// 严格模式，必须使用 mutations 修改，不能直接复制修改
	strict: true,
	actions,
	mutations,
	getters,
	state,
	modules: {
		login,
		menu,
		pagination,
		editWorkFlow,
		workflow,
		sceneInfo,
		intelligentReply,
		form,
		editWorkingTime,
		calendar,
		systemSetting,
		uploadVideo,
		associatedVariable,
		variable
	},
	plugins: [dataState]
});

// 为了解决npm方式store共享的问题
window.store = store;

// if (module.hot) {
// 	module.hot.accept(['./modules/workflow'], () => {
// 		store.hotUpdate({
// 			mutations: {},
// 			actions: {},
// 			modules: {
// 				workflow: require('./modules/workflow').default
// 			}
// 		});
// 	});
// }

export default store;
